package com.scuthnweb.service.impl;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Locale;

import com.scuthnweb.dao.AccountDao;
import com.scuthnweb.dao.ActionDao;
import com.scuthnweb.dao.Action_picDao;
import com.scuthnweb.dao.Action_summaryDao;
import com.scuthnweb.dao.MessageDao;
import com.scuthnweb.dao.RoleDao;
import com.scuthnweb.dao.TopDao;
import com.scuthnweb.domain.Account;
import com.scuthnweb.domain.Action;
import com.scuthnweb.domain.transfer.ActionList;
import com.scuthnweb.service.ActModule;

public class ActModuleImpl implements ActModule{
	
    private AccountDao accountDao;
    private RoleDao roleDao;
    private ActionDao actionDao;
    private Action_picDao action_picDao;
    private Action_summaryDao action_summaryDao;
	private MessageDao messageDao;
	private TopDao topDao;
    
	@Override
	public boolean createAct(Integer uid, String action_name, String introduction, String position, String join_time,String end_join_time, String start_time, String end_time) throws ParseException {
		Account account = this.accountDao.get(uid);
		Action action = new Action();
		
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
		action.setAction_name(action_name);
		action.setIntroduction(introduction);
		action.setPosition(position);
		action.setObj_status(0);
		action.setJoin_time( new java.sql.Timestamp(sdf.parse(join_time).getTime()) );
		action.setEnd_join_time( new java.sql.Timestamp(sdf.parse(end_join_time).getTime()) );
		action.setStart_time( new java.sql.Timestamp(sdf.parse(start_time).getTime()) );
		action.setEnd_time( new java.sql.Timestamp(sdf.parse(end_time).getTime()) );
		action.setAccount(account);
		action.setTop_pic("image/default/tree.png");
			
		return this.actionDao.create(action);
	}

	@Override
	public void deleteAct(Integer aid, Integer uid) {
		
	}

	@Override
	public void joinAct(Integer aid, Integer uid) {
		
	}

	@Override
	public void modifyAct() {
		
	}

	@Override
	public void offlineAct() {
		
	}

	@Override
	public void onlineAct() {
		
	}

	@Override
	public void quitAct() {
		
	}

	@Override
	public void checkUserJoinAct() {
		
	}

	@Override
	public void checkAct() {
		
	}

	@Override
	public ActionList checkAdminAct(Integer uid, Integer page, Integer pageSize) {
		return this.actionDao.findByUid(uid, page, pageSize);
	}

    public AccountDao getAccountDao() {
		return accountDao;
	}

	public void setAccountDao(AccountDao accountDao) {
		this.accountDao = accountDao;
	}

	public RoleDao getRoleDao() {
		return roleDao;
	}

	public void setRoleDao(RoleDao roleDao) {
		this.roleDao = roleDao;
	}

	public ActionDao getActionDao() {
		return actionDao;
	}

	public void setActionDao(ActionDao actionDao) {
		this.actionDao = actionDao;
	}

	public Action_picDao getAction_picDao() {
		return action_picDao;
	}

	public void setAction_picDao(Action_picDao action_picDao) {
		this.action_picDao = action_picDao;
	}

	public Action_summaryDao getAction_summaryDao() {
		return action_summaryDao;
	}

	public void setAction_summaryDao(Action_summaryDao action_summaryDao) {
		this.action_summaryDao = action_summaryDao;
	}

	public MessageDao getMessageDao() {
		return messageDao;
	}

	public void setMessageDao(MessageDao messageDao) {
		this.messageDao = messageDao;
	}

	public TopDao getTopDao() {
		return topDao;
	}

	public void setTopDao(TopDao topDao) {
		this.topDao = topDao;
	}
}
